# 1.导出在线售卖产品
# from utils.file_operation import process_excel
# process_excel('abcam_scale.xlsx', 'abcam_scale.json')

# 2.rj导出品牌在线商品信息
from rj.request import RequestHanlder
from utils.file_operation import save_dict_to_json

data_list = []

rj = RequestHanlder()

for page_num in range(1, 3):
    search_data = {
        "page": page_num,
        "size": 50,
        "brandIds": [989],
        "status": 3
    }
    res = rj.ProductList(search_data)
    data_list.extend(res.json()['data'])
save_dict_to_json(data_list, 'invent_online.json')

# rj查询商品详情
# from rj.request import RequestHanlder
# from utils.file_operation import save_dict_to_json, load_json_to_dict

# scale_json = load_json_to_dict('invent_online.json')
# ids = []
# invent_online = []

# rj = RequestHanlder()

# def generate_groups(elements, group_size=50):
#     """
#     生成器函数，按指定大小逐组产生元素

#     :param elements: 要分组的元素列表
#     :param group_size: 每组的大小，默认为50
#     :return: 逐个返回每组元素
#     """
#     for i in range(0, len(elements), group_size):
#         yield elements[i:i + group_size]

# # 创建ids列表
# for item in scale_json:
#     ids.append(item['id'])

# for group in generate_groups(ids):
#     res = rj.ProductsDetail(group)
#     invent_online.extend(res.json()['data'])

# save_dict_to_json(invent_online, 'invent_online_all.json')

# from utils.file_operation import save_dict_to_json, load_json_to_dict

# scale_json = load_json_to_dict('invent_online_all.json')

# save_dict_to_json(scale_json,'invent_online_all.json')

# save_dict_to_json(res, 'search_abcam_code.json')
# temp_list = load_json_to_dict('abcam_online.json')

# temp_code = []

# for item in temp_list:
#     temp_code.append(item['code'])

# res = list(set(temp_code))

# delete_list = []
# with open('log/log.txt','r',encoding='utf-8') as f:
#     res = f.readlines()
#     for line in res:
#         delete_list.append(line.split(' ')[-1].replace('\n',''))

# print(delete_list)
